From: Dan Winship Date: Tue, 8 Feb 2011 19:19:04 +0000 (-0500) Subject: popupMenu: minor code rearrangement X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~9098 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=5eb28e162f85e49ffb38bf81873cba77b588eb0d;p=gnome-shell.git popupMenu: minor code rearrangement Move the Switch class to right before PopupSwitchMenuItem (and add some missing semicolons). --- diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 30f353eb3..14b145077 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -18,35 +18,6 @@ const _ = Gettext.gettext; const SLIDER_SCROLL_STEP = 0.05; /* Slider scrolling step in % */ -function Switch() { - this._init.apply(this, arguments); -} - -Switch.prototype = { - _init: function(state) { - this.actor = new St.Bin({ style_class: 'toggle-switch' }); - // Translators: this MUST be either "toggle-switch-us" - // (for toggle switches containing the English words - // "ON" and "OFF") or "toggle-switch-intl" (for toggle - // switches containing "◯" and "|"). Other values will - // simply result in invisible toggle switches. - this.actor.add_style_class_name(_("toggle-switch-us")); - this.setToggleState(state); - }, - - setToggleState: function(state) { - if (state) - this.actor.add_style_pseudo_class('checked'); - else - this.actor.remove_style_pseudo_class('checked'); - this.state = state; - }, - - toggle: function() { - this.setToggleState(!this.state); - } -}; - function PopupBaseMenuItem(params) { this._init(params); } @@ -483,7 +454,7 @@ PopupSliderMenuItem.prototype = { _motionEvent: function(actor, event) { let absX, absY; [absX, absY] = event.get_coords(); - this._moveHandle(absX, absY) + this._moveHandle(absX, absY); return true; }, @@ -524,8 +495,37 @@ PopupSliderMenuItem.prototype = { } return false; } +}; + +function Switch() { + this._init.apply(this, arguments); } +Switch.prototype = { + _init: function(state) { + this.actor = new St.Bin({ style_class: 'toggle-switch' }); + // Translators: this MUST be either "toggle-switch-us" + // (for toggle switches containing the English words + // "ON" and "OFF") or "toggle-switch-intl" (for toggle + // switches containing "◯" and "|"). Other values will + // simply result in invisible toggle switches. + this.actor.add_style_class_name(_("toggle-switch-us")); + this.setToggleState(state); + }, + + setToggleState: function(state) { + if (state) + this.actor.add_style_pseudo_class('checked'); + else + this.actor.remove_style_pseudo_class('checked'); + this.state = state; + }, + + toggle: function() { + this.setToggleState(!this.state); + } +}; + function PopupSwitchMenuItem() { this._init.apply(this, arguments); } @@ -559,8 +559,7 @@ PopupSwitchMenuItem.prototype = { setToggleState: function(state) { this._switch.setToggleState(state); } -} - +}; function PopupImageMenuItem(text, iconName) { this._init(text, iconName);